package com.tudouji.project.system.controller;

import java.util.List;

import com.tudouji.common.utils.DateUtils;
import com.tudouji.common.utils.IdUtils;
import com.tudouji.common.utils.SecurityUtils;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.tudouji.framework.aspectj.lang.annotation.Log;
import com.tudouji.framework.aspectj.lang.enums.BusinessType;
import com.tudouji.project.system.domain.CusDepartGroup;
import com.tudouji.project.system.service.ICusDepartGroupService;
import com.tudouji.framework.web.controller.BaseController;
import com.tudouji.framework.web.domain.AjaxResult;
import com.tudouji.common.utils.poi.ExcelUtil;
import com.tudouji.framework.web.page.TableDataInfo;

/**
 * 部门客户关联Controller
 *
 * @author tudouji
 * @date 2021-02-01
 */
@RestController
@RequestMapping("/system/cusdepartgroup")
public class CusDepartGroupController extends BaseController
{
    @Autowired
    private ICusDepartGroupService cusdepartgroupService;

    /**
     * 查询部门客户关联列表
     */
    @PreAuthorize("@ss.hasPermi('system:cusdepartgroup:list')")
    @GetMapping("/list")
    public TableDataInfo list(CusDepartGroup cusdepartgroup)
    {
        startPage();
        List<CusDepartGroup> list = cusdepartgroupService.selectCusDepartGroupList(cusdepartgroup);
        return getDataTable(list);
    }

    /**
     * 导出部门客户关联列表
     */
    @PreAuthorize("@ss.hasPermi('system:cusdepartgroup:export')")
    @Log(title = "部门客户关联", businessType = BusinessType.EXPORT)
    @GetMapping("/export")
    public AjaxResult export(CusDepartGroup cusdepartgroup)
    {
        List<CusDepartGroup> list = cusdepartgroupService.selectCusDepartGroupList(cusdepartgroup);
        ExcelUtil<CusDepartGroup> util = new ExcelUtil<CusDepartGroup>(CusDepartGroup.class);
        return util.exportExcel(list, "cusdepartgroup");
    }

    /**
     * 获取部门客户关联详细信息
     */
    @PreAuthorize("@ss.hasPermi('system:cusdepartgroup:query')")
    @GetMapping(value = "/{guid}")
    public AjaxResult getInfo(@PathVariable("guid") String guid)
    {
        return AjaxResult.success(cusdepartgroupService.selectCusDepartGroupById(guid));
    }

    /**
     * 新增部门客户关联
     */
    @PreAuthorize("@ss.hasPermi('system:cusdepartgroup:add')")
    @Log(title = "部门客户关联", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody CusDepartGroup cusdepartgroup)
    {
        cusdepartgroup.setGuid(IdUtils.fastSimpleUUID());
        cusdepartgroup.setStatus(1);
        return toAjax(cusdepartgroupService.insertCusDepartGroup(cusdepartgroup));
    }

    /**
     * 修改部门客户关联
     */
    @PreAuthorize("@ss.hasPermi('system:cusdepartgroup:edit')")
    @Log(title = "部门客户关联", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody CusDepartGroup cusdepartgroup)
    {
        return toAjax(cusdepartgroupService.updateCusDepartGroup(cusdepartgroup));
    }

    /**
     * 删除部门客户关联
     */
    @PreAuthorize("@ss.hasPermi('system:cusdepartgroup:remove')")
    @Log(title = "部门客户关联", businessType = BusinessType.DELETE)
	@DeleteMapping("/{guids}")
    public AjaxResult remove(@PathVariable String[] guids)
    {
        return toAjax(cusdepartgroupService.deleteCusDepartGroupByIds(guids));
    }
}
